// <copyright file="EasyWebApp.cs" company="<Customer Name>">This is a "work-for-hire". or Copyright (C) 2010 MicroCODE Incorporated Troy, MI</copyright><author><Class Author's Name></author>

/*
 *      Title:    <Class Description>
 *      Module:   ClassTemplate (<Namespace>:ClassTemplate.cs)
 *      Project:  <Project Name>
 *      Customer: <Customer Name>
 *      Facility: MicroCODE Incorporated
 *      Date:     <Class Creation Date>
 *      Author:   <Class Author's Name>
 * 
 * 
 * 
 *  
 *      MODIFICATIONS:
 *      --------------
 *
 *  Date:         By-Group:   Rev:     Description:
 *
 *  DD-Mmm-YYYY   XYZ-GROUP  {0001}    Describe reason for creating or modifying class... 
 * 
 * 
 * 
 */
using System;
using System.Collections;
using System.Collections.Specialized;
using System.Data;
using System.Reflection;
using System.Web;
using System.Web.SessionState;
using Org.EasyWeb.Sys;
using Org.EasyWeb.Web;

namespace Org.EasyWeb.Data
{
    internal class ToolkitGlobalVariable : IGlobalVariable
    {
        // Fields
        public const string ApplicationData = "GlobalApplication";
        public const string SessionData = "GlobalSession";

        // Methods
        public ToolkitGlobalVariable()
        {
            if (HttpContext.Current != null)
            {
                HttpContext.Current.Application["GlobalApplication"] = new ApplicationGlobal();
            }
        }

        // Properties
        public IAppGlobal AppGbl
        {
            get
            {
                return (IAppGlobal)((HttpApplicationState)this.Application)["GlobalApplication"];
            }
        }

        public NameObjectCollectionBase Application
        {
            get
            {
                return HttpContext.Current.Application;
            }
        }

        public IUserInfo Info
        {
            get
            {
                return this.SessionGbl.Info;
            }
        }

        public RegsCollection RegsCollection
        {
            get
            {
                return this.AppGbl.RegsCollection;
            }
        }

        public HttpRequest Request
        {
            get
            {
                return HttpContext.Current.Request;
            }
        }

        public HttpResponse Response
        {
            get
            {
                return HttpContext.Current.Response;
            }
        }

        public HttpServerUtility Server
        {
            get
            {
                return HttpContext.Current.Server;
            }
        }

        public HttpSessionState Session
        {
            get
            {
                return HttpContext.Current.Session;
            }
        }

        public ISessionGlobal SessionGbl
        {
            get
            {
                return (ISessionGlobal)this.Session["GlobalSession"];
            }
        }

        public object UserID
        {
            get
            {
                return this.Info.UserID;
            }
        }
    }
}
